package com.orilore.gb.biz;

import java.sql.Connection;
import java.util.List;

import com.orilore.gb.dao.XUserDao;
import com.orilore.gb.entity.XUser;
import com.orilore.gb.util.Config;
import com.orilore.gb.util.ConnFactory;

public class XUserBiz {
	
	private XUserDao dao = new XUserDao();
	
	
	
	public List<XUser>  QueryPage(int curpage){
		
		
		 List<XUser>  list = null;
		 
		 try {
			Connection conn = ConnFactory.getConnection();
		
		     
			int begin = (curpage-1)*Config.pageSize;
		 
			list = dao.getPageQuery(conn, begin);
			
			ConnFactory.closeConnection(conn);
			
		 
		 
		 } catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 
		 
		 
		 
		 
		 
		 return list;
		
		
	}
	
	
	public int getPageCounts() {
		
		 int result = 0;
		 
			try {
				Connection conn = ConnFactory.getConnection();
				
				
				int counts = dao.queryCount(conn);
				
				
				if(counts%Config.pageSize==0) {
					
					
					result = counts/Config.pageSize;
					
				}
				
				else {
					
					result = counts/Config.pageSize+1;
					
				}
				
				
				
				
				
				
				
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		 
		 
		 
		 return result;
		  
		
		
		
		
	}
	
	
	
	
	
	

}
